package com.burges.net.key

import org.apache.flink.api.java.functions.KeySelector
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment, _}

/**
  * 通过Key选择器指定
  * 创建人    BurgessLee
  * 创建时间   2020/1/25
  * 描述
  */
object KetSelector {

	def main(args: Array[String]): Unit = {

		val env = StreamExecutionEnvironment.getExecutionEnvironment
		val data: DataStream[Person] = env.fromElements(Person("hello",1), Person("flink", 4))
		val dataKeyBy = data.keyBy(new KeySelector[Person, String] {
			override def getKey(person: Person): String = person.name
		})
		dataKeyBy.print()
	}

}

case class Person(name: String, age: Int)
